import 'package:json_annotation/json_annotation.dart';
part 'upload.g.dart';

@JsonSerializable()
class UploadResult {
  final bool success;
  final String message;
  final FileInfo data;

  const UploadResult(
    this.success,
    this.message,
    this.data,
  );

  factory UploadResult.fromJson(Map json) => _$UploadResultFromJson(json);
  Map toJson() => _$UploadResultToJson(this);
}

@JsonSerializable()
class UploadListResult {
  final bool success;
  final String message;
  final List<FileInfo> data;

  const UploadListResult(
    this.success,
    this.message,
    this.data,
  );

  factory UploadListResult.fromJson(Map json) =>
      _$UploadListResultFromJson(json);
  Map toJson() => _$UploadListResultToJson(this);
}

@JsonSerializable()
class FileInfo {
  final int id;
  final String name;
  final String key;
  final String type;
  final int size;
  final String url;

  FileInfo(
    this.id,
    this.name,
    this.key,
    this.type,
    this.size,
    this.url,
  );

  factory FileInfo.fromJson(Map json) => _$FileInfoFromJson(json);
  Map toJson() => _$FileInfoToJson(this);
}
